﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Text;

namespace ServiceMonitor.Core
{

    public enum MonitorType { Port, Http, StringBoot }

    public class MonitorConfig
    {
        public int Id { get; set; }
        public string Name { get; set; } = "New Monitor";
        public MonitorType Type { get; set; } = MonitorType.Port;
        public int CheckInterval { get; set; } = 30; // 秒
        public bool IsActive { get; set; } = true;

        // 公共告警设置
        public bool EnableEmailAlert { get; set; } = false;
        public string AlertEmail { get; set; } = "";

        // 端口检查配置
        public string Host { get; set; } = "localhost";
        public int Port { get; set; } = 80;

        // HTTP检查配置
        public string Url { get; set; } = "http://localhost";
        public int Timeout { get; set; } = 5000; // 毫秒
        public HttpStatusCode ExpectedStatus { get; set; } = HttpStatusCode.OK;

        public string JarPath { get; set; } = "";
        public string JavaArgs { get; set; } = "";
        public string WorkingDirectory { get; set; } = "";

        public override int GetHashCode()
        {
            return this.Id.GetHashCode();
        }

        public override bool Equals(object obj)
        {
            if (obj != null && obj is MonitorConfig config)
            {
                return this.Id == config.Id;
            }
            return false;
        }
    }


}
